package com.wntms.ywa.service.impl;


import com.github.pagehelper.PageHelper;
import com.wntms.ywa.dao.TmsDao;
import com.wntms.ywa.pojo.Details;
import com.wntms.ywa.pojo.FreightContract;
import com.wntms.ywa.service.FreightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class FreightServiceImpl implements FreightService {
    @Autowired
    private TmsDao tmsDao;
    //获取实例化对象
    FreightContract freightContract=new FreightContract();

    @Override
    public void add(FreightContract freightContract) {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
        String time = sdf.format(date);
        freightContract.setOccurtime(time);
        tmsDao.add(freightContract);
    }

    @Override
    public void deleteById(Integer id) {
        tmsDao.deleteById(id);
    }

    @Override
    public void deleteCustomerIn(Integer id) {
        tmsDao.deleteCustomerIn(id);
    }

    @Override
    public void deleteCustomerInforation(Integer id) {
        tmsDao.deleteCustomerInforation(id);
    }

    @Override
    public void deleteFreightLine(Integer id) {
        tmsDao.deleteFreightLine(id);
    }

    @Override
    public void deleteFreightInformation(Integer id) {
        tmsDao.deleteFreightInformation(id);
    }

    @Override
    public void update(FreightContract freightContract) {
        tmsDao.update(freightContract);
    }

    @Override
    public List<FreightContract> findIndex() {
        return tmsDao.findIndex();
    }
//分页
    @Override
    public List<FreightContract> findByPage(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<FreightContract> list=tmsDao.findIndex();
        return list;
    }

    @Override
    public List<Details> findDetails(Integer id) {
        return tmsDao.findDetails(id);
    }

    @Override
    public FreightContract findId(Integer id) {
        return tmsDao.findId(id);
    }


}

